﻿using Abp.Configuration.Startup;
using Abp.Modules;
using Abp.Web.Mvc;
using Abp.Web.SignalR;
using myu;
using myu.Api;
using Swashbuckle.Application;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Http;
using System.Web.Http.Cors;

namespace backYu
{
    [DependsOn(
        typeof(myuDataModule),
        typeof(myuApplicationModule),
        typeof(myuWebApiModule),
        typeof(AbpWebSignalRModule),
        //typeof(AbpHangfireModule), - ENABLE TO USE HANGFIRE INSTEAD OF DEFAULT JOB MANAGER
        typeof(AbpWebMvcModule))]
    public class MyuModule:AbpModule
    {

        /// <summary>
        /// The pre initialize.
        /// </summary>
        public override void PreInitialize()
        {

            //this.IocManager.Register<IPenseeSession, RecruitmentSession>();

            this.Configuration.Modules.AbpWeb().AntiForgery.IsEnabled = false;

            ////设置多租户
            this.Configuration.MultiTenancy.IsEnabled = true;
            this.Configuration.BackgroundJobs.IsJobExecutionEnabled = true;

            //跨域处理
            var cors = new EnableCorsAttribute("*", "*", "*");
            cors.SupportsCredentials = true;
            this.Configuration.Modules.AbpWebApi().HttpConfiguration.EnableCors(cors);

        }


        //private void ConfigureSwaggerUi()
        //{
        //    GlobalConfiguration.Configuration.EnableSwagger(
        //       c =>
        //       {
        //           c.UseFullTypeNameInSchemaIds();
        //           c.SingleApiVersion("v1", "backYu");
        //           c.ResolveConflictingActions(apiDescription => apiDescription.First());
        //           c.IncludeXmlComments($"{System.AppDomain.CurrentDomain.BaseDirectory}/bin/backYu.xml");
        //       })
        //           .EnableSwaggerUi(
        //           c =>
        //           {
        //           });
        //}

        /// <summary>
        /// 模块 初始化
        /// </summary>
        public override void Initialize()
        {
            this.IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());

            //ConfigureSwaggerUi();
        }

        /// <summary>
        /// The post initialize.
        /// </summary>
        public override void PostInitialize()
        {
            //var logger = this.IocManager.Resolve<ILogger>();
            //logger.Info("web加载完毕");

            //this.Configuration.Modules.AbpWebApi().HttpConfiguration.Routes.MapHttpRoute(
            //  name: "RecruitWebApi",
            //  routeTemplate: "api/testMyu/{controller}/{action}/{id}",
            //  defaults: new { id = RouteParameter.Optional });


            base.PostInitialize();
        }

    }
}